﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;

namespace MODASA.HojaDefinicionProducto
{
    public partial class HDPAcabadoInterno : System.Web.UI.Page
    {


        DataTable HDP;

        protected void Page_Load(object sender, EventArgs e)
        {



            if (Session["HDP"] == null)
            {
                Page.Response.Redirect("HDPModelos.aspx");

            }     
            
           


        }

        

        protected void RBLBAÑOPN_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("BañoPrimerNivel", RBLBAÑOPN.Text);
            if (RBLBAÑOPN.Text == "SI")
            {
                HLBAÑO1NIVEL.Visible = true;
                HLBAÑO1NIVEL.ImageUrl = "../images/Buses/ImgInt/Baño/m_Baño2.png";
                HLBAÑO1NIVEL.NavigateUrl = "../images/Buses/ImgInt/Baño/Baño2.png";
            }
            else
            {
                HLBAÑO1NIVEL.Visible = false;
            }
        }


        private void Añadir_Row_HDP(string A, string B) {
            

            HDP = (DataTable)Session["HDP"];


            for (int x = 0; x < HDP.Rows.Count; x++)
            {
                string A1 = HDP.Rows[x][0].ToString();

                if (A1.ToString() == A.ToString())
                {
                    HDP.Rows.RemoveAt(x);

                }
            }

            HDP.Rows.Add(A, B);

        }

        protected void RBLBAÑOSN_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (RBLBAÑOSN.Text == "SI")
            {
                HLBAÑO2NIVEL.Visible = true;
                HLBAÑO2NIVEL.ImageUrl = "../images/Buses/ImgInt/Baño/m_Baño1.png";
                HLBAÑO2NIVEL.NavigateUrl = "../images/Buses/ImgInt/Baño/Baño1.png";
           
            }
            else
            {
                HLBAÑO2NIVEL.Visible = false;
            }

            Añadir_Row_HDP("BañoSegundoNivel", RBLBAÑOSN.Text);
        }

        protected void RBLCAMARIN_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("CamaroteInstalacion", RBLCAMARIN.Text);

            HabilitarDesabilitarOpCamarote(RBLCAMARIN.Text);

        }

        private void HabilitarDesabilitarOpCamarote (string res)
        {


            if (res == "NO")
            {
                RBLCAMARPU.Enabled = false;
                RBLCAMARUB.Enabled = false;

            }
            else if (res == "SI")
            {
                RBLCAMARUB.Enabled = true;
                RBLCAMARPU.Enabled = true;
            }


        }

        protected void RBLCAMARUB_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("CamaroteUbicacion", RBLCAMARUB.Text);
        }

        protected void RBLCAMARPU_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("CamarotePuerta", RBLCAMARPU.Text);
        }

        protected void RBLMUE1NPAS_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("MueblePrimerNivelPasillo", RBLMUE1NPAS.Text);
        }

        protected void RBLMUE1NSAL_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("MueblePrimerNivelSalon", RBLMUE1NSAL.Text);
        }

        protected void RBLMUE2NSUB_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("MuebleSegundoNivelSubida", RBLMUE2NSUB.Text);
        }

        protected void RBLMUE2NCOC_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("MuebleSegundoNivelCocina", RBLMUE2NCOC.Text);
        }

        protected void RBLREFRIN_SelectedIndexChanged(object sender, EventArgs e)
        {
            CargarImgRefrigeracion(RBLREFRIN.SelectedValue);
        }
        private void CargarImgRefrigeracion(string res) { 
        Añadir_Row_HDP("EquipoRefrigeracionInstalacion",res);
        if (res == "SI")
        {
            HLREFRIGERACION.Visible = true;
            HLREFRIGERACION.ImageUrl = "../images/Buses/ImgInt/AcabadoInterno/m_Refrigeracion.png";
            HLREFRIGERACION.NavigateUrl = "../images/Buses/ImgInt/AcabadoInterno/Refrigeracion.png";
        }
        else {
            HLREFRIGERACION.Visible = false;
        
        }
        
        }

        protected void RBLFORRLAT_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("ForradoLaterales", RBLFORRLAT.Text);
        }

        protected void RBLFORRCENT_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("ForradoCentrales", RBLFORRCENT.Text);
        }

        protected void RBLCORTTIP_SelectedIndexChanged(object sender, EventArgs e)
        {
            CargarImgCortinas(RBLCORTTIP.SelectedValue);
        }

        private void CargarImgCortinas(string res) {

            Añadir_Row_HDP("CortinasTipo", RBLCORTTIP.Text);
            HLCORTINAS.ImageUrl = "../images/Buses/ImgInt/AcabadoInterno/Cortinas/m_" + res + ".jpg";
            HLCORTINAS.NavigateUrl = "../images/Buses/ImgInt/AcabadoInterno/Cortinas/"+res+".jpg";
        }


        protected void RBLSUJPARTIP_SelectedIndexChanged(object sender, EventArgs e)
        {
            Añadir_Row_HDP("SujetadoresParabrisas2NTipo", RBLSUJPARTIP.Text);
        }


        protected void RBLSUJCORIN_SelectedIndexChanged(object sender, EventArgs e)
        {
            CargarImgSujetadores(RBLSUJCORIN.Text);
        }
        private void CargarImgSujetadores(string res) {
            if (res == "SI")
            {
                HLSUJETADOR.Visible = true;
                HLSUJETADOR.ImageUrl = "../images/Buses/ImgInt/AcabadoInterno/Cortinas/m_Sujetador.jpg";
                HLSUJETADOR.NavigateUrl = "../images/Buses/ImgInt/AcabadoInterno/Cortinas/Sujetador.jpg";
            }
            else {
                HLSUJETADOR.Visible = false;
            }

            Añadir_Row_HDP("SujetadoresCortinasInstalacion", RBLSUJCORIN.Text);
        }

    }
}